import request from 'alinesno-ui/src/utils/request'

var prefix = 'com/alinesno/cloud/business/buildProjectInfo/';

var managerUrl = {
  initMyApplication: prefix + "initMyApplication",
  detail: prefix + "detail",
}

// 获取应用列表
export function initMyApplication() {
  return request({
    url: managerUrl.initMyApplication,
    method: 'get',
  })
}

// 获取应用详情
export function applicationDetail(id) {
  return request({
    timeout:10000,
    url: managerUrl.detail + '/' + id,
    method: 'get',
  })
}

// 保存构建参数
export function buildProjectParams(data) {
  return request({
    url: 'api/deployment/cicd/publicProject',
    method: 'post',
    data: data
  })
}

// 获取构建参数
export function getBuildProjectParams(projectId) {
  return request({
    url: 'api/deployment/cicd/projectBuildInfo/' + projectId,
    method: 'get'
  })
}

// 构建发布到gitlab基线
export function buildGitlab(projectId) {
  return request({
    url: 'api/deployment/cicd/buildGitlab/' + projectId,
    method: 'get'
  })
}

// 发布到Jenkins打包镜像
export function buildDocker(projectId) {
  return request({
    url: 'api/deployment/cicd/buildDocker/' + projectId,
    method: 'get'
  })
}

// 发布Jenkins运行状态buildDockerStatus
export function buildDockerStatus(projectId) {
  return request({
    url: 'api/deployment/cicd/buildDockerStatus/' + projectId,
    method: 'get'
  })
}

// 发布到k8s容器
export function buildK8S(projectId) {
  return request({
    url: 'api/deployment/cicd/buildK8S/' + projectId,
    method: 'get'
  })
}

// 获取到应用模板
export function getTemplate(businessType) {
  return request({
    url: 'com/alinesno/cloud/business/buildApplicationTemplate/getTemplate?businessType=' + businessType,
    method: 'get'
  })
}

// 生成模板应用
export function generatorTemplateProject(data) {
  return request({
    url: 'com/alinesno/cloud/initializr/initiallizrSeed/generatorTemplateProject',
    method: 'post',
    data: data
  })
}

/**
 * 验证项目标识是否存在
 */
export function validateProjectCode(projectCode) {
  return request({
    url: 'com/alinesno/cloud/initializr/initiallizrSeed/genProjectCode/' + projectCode,
    method: 'get'
  })
}

/**
 * 获取统计数据
 */
export function getStaticsData() {
  return request(
    {
      url: 'com/alinesno/cloud/initializr/statics',
      method: 'get'
    }
  )
}
